from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from .views import statistical
from .views import users
from rest_framework.routers import SimpleRouter, DefaultRouter
from .views import specs
from .views import spu
from .views import sku
from .views import category
from .views import sku_image
from .views import order
from .views import admin_permission
from .views import admin_group
from .views import admin_user
from .views import brand
from .views import channels


urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    # 1.用户总量统计
    url('^statistical/total_count/$', statistical.TotalView.as_view()),
    # 2.日增用户统计
    url('^statistical/day_increment/$', statistical.DayView.as_view()),
    # 3.日活跃用户统计
    url('^statistical/day_active/$', statistical.ActiveView.as_view()),
    # 4.日下单用户统计
    url('^statistical/day_orders/$', statistical.OrderView.as_view()),
    # 5.月增量用户统计
    url('^statistical/month_increment/$', statistical.MonthView.as_view()),
    # 6.日分类商品访问量
    url('^statistical/goods_day_views/$', statistical.GoodsView.as_view()),

    # 7.用户管理
    url('^users/$', users.UserView.as_view()),

    url('^goods/simple/$', spu.SpuSimpleView.as_view()),

    # 9.查询三级分类名称
    url('^skus/categories/$', category.Category3View.as_view()),

    # 10.查询指定spu的规格以及选项
    url('^goods/(?P<pk>\d+)/specs/$', specs.SpecOptionView.as_view()),

    # 11.查询所有sku
    url('^skus/simple/$', sku.SkuSimpleView.as_view()),

    url('^permission/simple/$', admin_permission.PermissionSimpleView.as_view()),

    url('^permission/groups/simple/$', admin_group.GroupSimpleView.as_view()),

    url('^goods/brands/simple/$', spu.BrandView.as_view()),

    url('^goods/channel/categories/$', spu.FirstView.as_view()),

    url('^goods/channel/categories/(?P<pk>\d+)/$', spu.SecondView.as_view()),

    # 获取品牌信息
    url('^goods/specs/simple/$', specs.SpecSimpleView.as_view()),

    url('^goods/channel_types/$', channels.ChannelsSimpleView.as_view()),

    url('^goods/categories/$', channels.ChannelsCategoryView.as_view()),

    url('^goods/images/$', spu.ImageView.as_view()),
]

router = DefaultRouter()
router.register('goods/specs', specs.SpecViewSet, base_name='specs')
router.register('skus/images', sku_image.ImageViewSet, base_name='images')
router.register('skus', sku.SkuViewSet, base_name='skus')
router.register('orders', order.OrderViewSet, base_name='orders')
router.register('permission/perms', admin_permission.PermissionViewSet, base_name='permission')
router.register('permission/groups', admin_group.GroupViewSet, base_name='group')
router.register('permission/admins', admin_user.UserViewSet, base_name='admin')
router.register('goods/brands', brand.BrandViewSet, base_name='brand')
# 频道表
router.register('goods/channels', channels.ChannelsView, base_name='channels')
router.register('goods', spu.SpuViewSet, base_name='goods')
router.register('specs/options', specs.SpecSaveViewSet, base_name='option')
# 频道表
# router.register('channels', channels.ChannelsView, base_name='channels')
urlpatterns += router.urls
